<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page session="false" %>
<%@ page isELIgnored ="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<script type="text/javascript">
//<![CDATA[
(function(){
	dojo.byId("lbl_calendar_new_affair").innerHTML = Organization._resource.affair ;
	$kdom.appendDojoProp("input_calendar_new_affair","missingMessage",$ksub(KppModule.commonResource.missingMessage,[Organization._resource.organizationCode]));
	dojo.byId("lbl_calendar_new_begindate").innerHTML = Organization._resource.beginDate;
	dojo.byId("lbl_calendar_new_enddate").innerHTML = Organization._resource.endDate;
	dojo.byId("lbl_calendar_new_monday").innerHTML = Organization._resource.monday;
	dojo.byId("lbl_calendar_new_tuesday").innerHTML = Organization._resource.tuesday;
	dojo.byId("lbl_calendar_new_wednesday").innerHTML = Organization._resource.wednesday;
	dojo.byId("lbl_calendar_new_thursday").innerHTML = Organization._resource.thursday;
	dojo.byId("lbl_calendar_new_friday").innerHTML = Organization._resource.friday;
	dojo.byId("lbl_calendar_new_saturday").innerHTML = Organization._resource.saturday;
	dojo.byId("lbl_calendar_new_sunday").innerHTML = Organization._resource.sunday;
	$kdom.appendDojoProp("btn_calrule_new_save","label",KppModule.commonResource.save);
	$kdom.appendDojoProp("btn_calrule_new_cancel","label",KppModule.commonResource.cancel);
})();

function dateCompare() {
	var startTime = dijit.byId("input_calendar_new_begindate").getValue();
	var endTime = dijit.byId("input_calendar_new_enddate").getValue();
	if(startTime != null && endTime != null ){
		if(Date.parse(startTime)<Date.parse(endTime)){
			dijit.byId("btn_calrule_new_save").setDisabled(false);
		} else {
			dijit.byId("btn_calrule_new_save").setDisabled(true);
			dialogShow("calrule_new_dateWarn",Organization._resource.dateWarn);
		};
	}
}

function dialogShow(dlgId,content) {
	this.dlg=dijit.byId(dlgId);
	if(!this.dlg)this.dlg=new dijit.Dialog({
		id:dlgId,
		title: KppModule.commonResource.hint,
		style: "padding:0px;width:300px;height:100px;background-color:#FFF;"});
		this.dlg.set("content","<div style=\"padding:20px;text-align:center\">"+content+"</div>");
	this.dlg.show();
}

//]]>
</script>
<span style="display:none">To solve IE7/8 script event tag problem.</span>
<div data-dojo-type="dijit.form.Form" data-dojo-props="action:'../../organization/calendar/newrule.do?oid=${orgId}',id:'frm_calendar_role_new'">
	<table width="100%" cellspacing="10">
		<tr>
			<td><label id="lbl_calendar_new_affair">calendar rule affair</label></td>
			<td colspan="7" ><input id="input_calendar_new_affair" data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="required:true,trim:true,name:'affair',maxLength:20"></input></td>
		</tr>
		<tr>
			<td><label id="lbl_calendar_new_begindate">calendar rule begin date</label></td>
			<td colspan="7">
				<input id="input_calendar_new_begindate" data-dojo-type="dijit/form/DateTextBox" data-dojo-props="required:true,name:'beginDate'"></input>
			</td>
		</tr>
		<tr>
			<td><label id="lbl_calendar_new_enddate">calendar rule end date</label></td>
			<td colspan="7">
				<input id="input_calendar_new_enddate" data-dojo-type="dijit/form/DateTextBox" data-dojo-props="required:true,name:'endDate',onBlur:dateCompare"></input>
			</td>
		</tr>
		<tr>
			<td><label id="lbl_calendar_new_monday">Monday</label><input id="input_calendar_new_monday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'monday'"></input></td>
			<td><label id="lbl_calendar_new_tuesday">Tuesday</label><input id="input_calendar_new_tuesdat" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'tuesday'"></input></td>
			<td><label id="lbl_calendar_new_wednesday">Wednesday</label><input id="input_calendar_new_wednesday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'wednesday'"></input></td>
			<td><label id="lbl_calendar_new_thursday">Thursday</label><input id="input_calendar_new_thursday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'thursday'"></input></td>
			<td><label id="lbl_calendar_new_friday">Friday</label><input id="input_calendar_new_friday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'friday'"></input></td>
			<td><label id="lbl_calendar_new_saturday">Saturday</label><input id="input_calendar_new_saturday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'saturday'"></input></td>
			<td><label id="lbl_calendar_new_sunday">Sunday</label><input id="input_calendar_new_sunday" data-dojo-type="dijit/form/CheckBox" data-dojo-props="required:true,name:'sunday'"></input></td>
		</tr>
	</table>
</div>
<div class="dialogFooter">
	<div id="btn_calrule_new_save" data-dojo-type="dijit.form.Button" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconSave', showLabel:true" style="width:70px;">
		<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
			var options = {
				domain:Organization._resource.rule,
				refresh:Calendar.ruleRefresh,
				button:this,
				dialogId:"dialog_org_calrule_new",
				formId:"frm_calendar_role_new",
				resource:Organization._resource
			};
			KppModule.restProxy(options).postNew();
		</script>
	</div>
	<div id="btn_calrule_new_cancel" data-dojo-type="dijit.form.Button" data-dojo-props="iconClass:'dijitEditorIcon dijitEditorIconUndo', showLabel:true" style="width:70px;">
		<script type="dojo/on" data-dojo-event="click" data-dojo-args="evt">
				dijit.byId("dialog_org_calrule_new").hide();
		</script>
	</div>
</div>